package ArrayTest;

import java.util.Arrays;

public class ShellSort {
    public static void main(String[] args) {
        int []arr={5,7,3,1,6,9,4,2,8,0};
        for (int gap = arr.length/2; gap >0 ; gap/=2) {
            for (int i = gap; i <arr.length ; i++) {
                for (int j = i-gap; j >=0 ; j-=gap) {
                    if (arr[j]>arr[j+gap]){
                        int t;
                        t=arr[j];
                        arr[j]=arr[j+gap];
                        arr[j+gap]=t;
                        System.out.println(Arrays.toString(arr));
                    }else {
                        break;
                    }
                }
                System.out.println();
            }
        }
        System.out.println(Arrays.toString(arr));
    }
}
